import * as VueRouter from "vue-router";

// routes
const routes = [
  {
    path: "/",
    redirect: "home",
  },
  {
    path: "/main",
    name: "main",
    component: () => import("@/views/main/index.vue"),
    children: [
      {
        path: "/home",
        name: "homoe",
        component: () => import("@/views/home/index.jsx"),
      },
      {
        path: "/rspack",
        name: "rspack",
        component: () => import("@/views/rspack/index.jsx"),
      },
    ],
  },
];

/**
 * 创建router实例
 *
 */
const router = VueRouter.createRouter({
  history: VueRouter.createWebHashHistory(),
  // history: VueRouter.createWebHistory(),
  routes,
  scrollBehavior(to, from, savedPosition) {
    // 始终滚动到顶部
    return { top: 0 };
  },
});
// 路由守卫
router.beforeEach((to, from, next) => {
  next();
});
export default router;
